<!-- templates/admin/user-form.html -->
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title th:text="${user.userID != null} ? '编辑用户' : '新建用户'"></title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
</head>
<body>
<div th:replace="common/navbar :: navbar"></div>

<div class="container mt-4">
    <h2 class="mb-4" th:text="${user.userID != null} ? '编辑快递员' : '新建快递员'"></h2>

    <form th:action="@{/admin/users}" method="post">
        <div th:if="${error}" class="alert alert-danger" th:text="${error}"></div>

        <div class="row">
            <div class="col-md-6">
                <div class="mb-3">
                    <label class="form-label">工号</label>
                    <input type="text" class="form-control"
                           th:field="*{user.userID}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">姓名</label>
                    <input type="text" class="form-control"
                           th:field="*{user.userName}" required>
                </div>
            </div>

            <div class="col-md-6">
                <div class="mb-3">
                    <label class="form-label">邮箱</label>
                    <input type="email" class="form-control"
                           th:field="*{user.email}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">密码</label>
                    <input type="password" class="form-control"
                           th:field="*{user.password}" required>
                </div>

                <div class="mb-3">
                    <label class="form-label">确认密码</label>
                    <input type="password" class="form-control"
                           name="confirmPassword" required>
                </div>
            </div>
        </div>

        <div class="d-grid gap-2 d-md-flex justify-content-md-end">
            <button type="submit" class="btn btn-primary">
                <i class="bi bi-check-circle"></i> 提交
            </button>
            <a th:href="@{/admin/users}" class="btn btn-secondary">
                取消
            </a>
        </div>
    </form>
</div>
</body>
</html>